import request from "@/utils/request";

// 查询考勤记录列表
export function listRecord(query) {
  return request({
    url: "/system/record/list",
    method: "get",
    params: query,
  });
}

// 查询考勤记录详细
export function getRecord(id) {
  return request({
    url: "/system/record/" + id,
    method: "get",
  });
}

// 新增考勤记录
export function addRecord(data) {
  return request({
    url: "/system/record",
    method: "post",
    data: data,
  });
}

// 修改考勤记录
export function updateRecord(data) {
  return request({
    url: "/system/record",
    method: "put",
    data: data,
  });
}

// 删除考勤记录
export function delRecord(id) {
  return request({
    url: "/system/record/" + id,
    method: "delete",
  });
}

// 上班打卡
export function checkIn() {
  return request({
    url: "/system/record/checkIn",
    method: "post",
  });
}

// 下班打卡
export function checkOut() {
  return request({
    url: "/system/record/checkOut",
    method: "post",
  });
}

// 获取今日考勤状态
export function getTodayStatus() {
  return request({
    url: "/system/record/todayStatus",
    method: "get",
  });
}

// @/api/system/record.js
// import request from "@/utils/request";

// export function checkIn() {
//   return request({
//     url: "/attendance/checkIn",
//     method: "post",
//   });
// }

export function updateCheckInNotes(recordId, notes) {
  return request({
    url: `/attendance/updateCheckInNotes/${recordId}`,
    method: "post",
    data: { notes },
  });
}
export function updateAttendanceRecordNotes(data) {
  return request({
    url: "/system/record/updateNotes",
    method: "put",
    data,
  });
}
export function updateAttendanceRemark(data) {
  return request({
    url: "/system/record/updateRemark",
    method: "put",
    data: data,
  });
}

//根据IP定位
export function getIpLocation(ip) {
  return request({
    url: '/map/ip/location',
    method: 'get',
    params: { ip }
  })
}
